package hc.bre.rest.auth

import org.junit.jupiter.api.Test

import hc.bre.rest.admin.BreAdminConfig
import hc.bre.rest.admin.BreAdminService
import hc.bre.rest.admin.BrePermission

@groovy.transform.CompileStatic
class AuthTest {
	@Test
	void create() {
		BreAdminConfig security = BreAdminConfig.create();
		assert security.roleList[0].code == 'Administrators'
		assert security.userList[0].code == 'admin'
	}

	@Test
	void load() {
		BreAdminService service = new BreAdminService(){
					@Override
					public String getFileName() {
						return "c:/temp/application.config";
					}
				}

		BreAdminConfig security = service.load()

		String jsonText =  hc.Util.jsonWrite(security);
		service.save(hc.Util.jsonRead(jsonText));


		BreAdminConfig security2 = service.load()
		assert security.version +1 ==security2.version;
	}

	@Test
	void Permission() {
		println BrePermission.list();
	}
}
